//
//  CBJStatuesRewteetedView.swift
//  Weibo
//
//  Created by 崔健 on 16/5/25.
//  Copyright © 2016年 cbj. All rights reserved.
//

import UIKit

class CBJStatuesRewteetedView: UIView {

    
    var statuesVM : CBJStatuesViewModel? {
        
        didSet{
            
            // 数据绑定
            nameLabel.text = statuesVM?.statues?.retweeted_status?.user?.name
            sourceLabel.text = statuesVM?.sourceText
            timeLabel.text = statuesVM?.timeFomate
            contentLabel.text = statuesVM?.statues?.retweeted_status?.text
            pictureView.pictureList = statuesVM?.statues?.retweeted_status?.pic_urls
            
        }
    }
    
    
    lazy var testLabel = UILabel(text: "cadfsjfl", font: 15)
    
    override init(frame: CGRect) {
        
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.9, alpha: 1)

        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    lazy private var nameLabel : UILabel = UILabel(text: "", font: 14)
    lazy private var sourceLabel : UILabel = UILabel(text : "" , font: 10)
    lazy private var timeLabel : UILabel = UILabel(text : "" , font: 10)
    lazy private var contentLabel : UILabel = UILabel(text :"dddddddd" , font: 14 ,textColor: UIColor.darkGrayColor() , alignment: .Left)
    lazy private var pictureView : CBJStatuesPictureView = CBJStatuesPictureView()
    
    func setupUI(){
        
        addSubview(nameLabel)
        addSubview(sourceLabel)
        addSubview(timeLabel)
        addSubview(contentLabel)
        addSubview(pictureView)
        
        nameLabel.snp_makeConstraints { (make) in
            
            make.top.equalTo(self)
            make.left.equalTo(self).offset(margin)
        }
        
        timeLabel.snp_makeConstraints { (make) in
            
            make.centerY.equalTo(nameLabel)
            make.left.equalTo(nameLabel.snp_right).offset(margin)
        }
        
        sourceLabel.snp_makeConstraints { (make) in
            
            make.left.equalTo(timeLabel.snp_right).offset(margin)
            make.top.equalTo(timeLabel)
        }
        
        contentLabel.snp_makeConstraints { (make) in
            
            make.left.equalTo(self).offset(margin)
            make.top.equalTo(nameLabel.snp_bottom)
            make.right.equalTo(self).offset(-margin)
        }
        
        pictureView.snp_makeConstraints { (make) in
            
            make.top.equalTo(contentLabel.snp_bottom)
            make.left.equalTo(self).offset(margin)
            
        }
        
        self.snp_makeConstraints { (make) in
            
            make.bottom.equalTo(pictureView)
        }

        
    }
    

}
